package old;

import java.io.IOException;


import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import robot.PMF;

import modeles.News;


public class SupprimerNewsServlet extends HttpServlet {

	private static final long serialVersionUID = -2502133846514921463L;
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)	throws IOException {
		resp.setContentType("text/plain");
		String nomNewsASupprimer = req.getParameter("newsSelection");
		System.out.println("nom news a supprimer : "+nomNewsASupprimer);
		PersistenceManager pm = PMF.get().getPersistenceManager();
		News news = null;
		try{
			news = pm.getObjectById(News.class,nomNewsASupprimer);
			pm.deletePersistent(news);
		}catch(JDOObjectNotFoundException e){
			e.printStackTrace();
			System.out.println("news introuvable");
		}
		resp.sendRedirect("/panneauAdministration/modificationNews.jsp");
	}
}
